﻿using System;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using BeerStats.Models;

namespace BeerStats.Data.Mappings
{
    public class BeerMap : EntityTypeConfiguration<Beer>
    {
        public BeerMap()
        {
            this.HasKey(b => b.BeerId);

            this.Property(b => b.Name)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(b => b.AlcoholByVolume)
                .IsRequired();

            this.Property(b => b.BreweryName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(b => b.Description)
                .IsRequired()
                .HasMaxLength(1000);

            this.Property(b => b.ImageSource)
                .IsRequired()
                .HasMaxLength(255);

            this.Property(b => b.Rating)
                .IsOptional();
        }
    }
}
